Integrand size = 13, antiderivative size = 73 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=\frac {a \left (a^2-b^2\right ) x}{2 \left (a^2+b^2\right )^2}-\frac {a^2 b \log (b \cos (x)+a \sin (x))}{\left (a^2+b^2\right )^2}+\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )} \]
1/2*a*(a^2-b^2)*x/(a^2+b^2)^2-a^2*b*ln(b*cos(x)+a*sin(x))/(a^2+b^2)^2+1/2* (b+a*cot(x))*sin(x)^2/(a^2+b^2)
Result contains complex when optimal does not.
Time = 0.50 (sec) , antiderivative size = 82, normalized size of antiderivative = 1.12 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=\frac {4 i a^2 b \arctan (\tan (x))-b \left (a^2+b^2\right ) \cos (2 x)+a \left (2 (a-i b)^2 x-2 a b \log \left ((b \cos (x)+a \sin (x))^2\right )+\left (a^2+b^2\right ) \sin (2 x)\right )}{4 \left (a^2+b^2\right )^2} \]
((4*I)*a^2*b*ArcTan[Tan[x]] - b*(a^2 + b^2)*Cos[2*x] + a*(2*(a - I*b)^2*x - 2*a*b*Log[(b*Cos[x] + a*Sin[x])^2] + (a^2 + b^2)*Sin[2*x]))/(4*(a^2 + b^ 2)^2)
Time = 0.36 (sec) , antiderivative size = 124, normalized size of antiderivative = 1.70, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.538, Rules used = {3042, 3999, 601, 25, 27, 657, 2009}
Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.
\(\displaystyle \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {\sin \left (x+\frac {\pi }{2}\right )^2}{a-b \tan \left (x+\frac {\pi }{2}\right )}dx\) |
\(\Big \downarrow \) 3999 |
\(\displaystyle -b \int \frac {b^2 \cot ^2(x)}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )^2}d(b \cot (x))\) |
\(\Big \downarrow \) 601 |
\(\displaystyle -b \left (-\frac {\int -\frac {a b^2 (a-b \cot (x))}{\left (a^2+b^2\right ) (a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )}d(b \cot (x))}{2 b^2}-\frac {a b \cot (x)+b^2}{2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 25 |
\(\displaystyle -b \left (\frac {\int \frac {a b^2 (a-b \cot (x))}{\left (a^2+b^2\right ) (a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )}d(b \cot (x))}{2 b^2}-\frac {a b \cot (x)+b^2}{2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 27 |
\(\displaystyle -b \left (\frac {a \int \frac {a-b \cot (x)}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )}d(b \cot (x))}{2 \left (a^2+b^2\right )}-\frac {a b \cot (x)+b^2}{2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 657 |
\(\displaystyle -b \left (\frac {a \int \left (\frac {2 a}{\left (a^2+b^2\right ) (a+b \cot (x))}+\frac {a^2-2 b \cot (x) a-b^2}{\left (a^2+b^2\right ) \left (\cot ^2(x) b^2+b^2\right )}\right )d(b \cot (x))}{2 \left (a^2+b^2\right )}-\frac {a b \cot (x)+b^2}{2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 2009 |
\(\displaystyle -b \left (\frac {a \left (\frac {\left (a^2-b^2\right ) \arctan (\cot (x))}{b \left (a^2+b^2\right )}-\frac {a \log \left (b^2 \cot ^2(x)+b^2\right )}{a^2+b^2}+\frac {2 a \log (a+b \cot (x))}{a^2+b^2}\right )}{2 \left (a^2+b^2\right )}-\frac {a b \cot (x)+b^2}{2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
-(b*(-1/2*(b^2 + a*b*Cot[x])/((a^2 + b^2)*(b^2 + b^2*Cot[x]^2)) + (a*(((a^ 2 - b^2)*ArcTan[Cot[x]])/(b*(a^2 + b^2)) + (2*a*Log[a + b*Cot[x]])/(a^2 + b^2) - (a*Log[b^2 + b^2*Cot[x]^2])/(a^2 + b^2)))/(2*(a^2 + b^2))))
3.1.13.3.1 Defintions of rubi rules used
Int[(a_)*(Fx_), x_Symbol] :> Simp[a Int[Fx, x], x] /; FreeQ[a, x] && !Ma tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
Int[(x_)^(m_)*((c_) + (d_.)*(x_))^(n_.)*((a_) + (b_.)*(x_)^2)^(p_), x_Symbo l] :> With[{Qx = PolynomialQuotient[x^m*(c + d*x)^n, a + b*x^2, x], e = Coe ff[PolynomialRemainder[x^m*(c + d*x)^n, a + b*x^2, x], x, 0], f = Coeff[Pol ynomialRemainder[x^m*(c + d*x)^n, a + b*x^2, x], x, 1]}, Simp[(a*f - b*e*x) *((a + b*x^2)^(p + 1)/(2*a*b*(p + 1))), x] + Simp[1/(2*a*(p + 1)) Int[(c + d*x)^n*(a + b*x^2)^(p + 1)*ExpandToSum[(2*a*(p + 1)*Qx)/(c + d*x)^n + (e* (2*p + 3))/(c + d*x)^n, x], x], x]] /; FreeQ[{a, b, c, d}, x] && IGtQ[m, 1] && LtQ[p, -1] && ILtQ[n, 0] && NeQ[b*c^2 + a*d^2, 0]
Int[(((d_.) + (e_.)*(x_))^(m_.)*((f_.) + (g_.)*(x_))^(n_.))/((a_) + (c_.)*( x_)^2), x_Symbol] :> Int[ExpandIntegrand[(d + e*x)^m*((f + g*x)^n/(a + c*x^ 2)), x], x] /; FreeQ[{a, c, d, e, f, g, m}, x] && IntegersQ[n]
Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_ ), x_Symbol] :> Simp[b/f Subst[Int[x^m*((a + x)^n/(b^2 + x^2)^(m/2 + 1)), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && IntegerQ[m/2]
Time = 0.40 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.34
method | result | size |
default | \(-\frac {a^{2} b \ln \left (\tan \left (x \right ) a +b \right )}{\left (a^{2}+b^{2}\right )^{2}}+\frac {\frac {\left (\frac {1}{2} a^{3}+\frac {1}{2} a \,b^{2}\right ) \tan \left (x \right )-\frac {a^{2} b}{2}-\frac {b^{3}}{2}}{\tan \left (x \right )^{2}+1}+\frac {a \left (a b \ln \left (\tan \left (x \right )^{2}+1\right )+\left (a^{2}-b^{2}\right ) \arctan \left (\tan \left (x \right )\right )\right )}{2}}{\left (a^{2}+b^{2}\right )^{2}}\) | \(98\) |
risch | \(\frac {x a}{4 i a b +2 a^{2}-2 b^{2}}-\frac {i {\mathrm e}^{2 i x}}{8 \left (i b +a \right )}+\frac {i {\mathrm e}^{-2 i x}}{-8 i b +8 a}+\frac {2 i a^{2} b x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {a^{2} b \ln \left ({\mathrm e}^{2 i x}+\frac {i b -a}{i b +a}\right )}{a^{4}+2 a^{2} b^{2}+b^{4}}\) | \(127\) |
-a^2*b/(a^2+b^2)^2*ln(tan(x)*a+b)+1/(a^2+b^2)^2*(((1/2*a^3+1/2*a*b^2)*tan( x)-1/2*a^2*b-1/2*b^3)/(tan(x)^2+1)+1/2*a*(a*b*ln(tan(x)^2+1)+(a^2-b^2)*arc tan(tan(x))))
Time = 0.30 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.30 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=-\frac {a^{2} b \log \left (2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}\right ) + {\left (a^{2} b + b^{3}\right )} \cos \left (x\right )^{2} - {\left (a^{3} + a b^{2}\right )} \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{3} - a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \]
-1/2*(a^2*b*log(2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 + a^2) + (a^2*b + b^3)*cos(x)^2 - (a^3 + a*b^2)*cos(x)*sin(x) - (a^3 - a*b^2)*x)/(a^4 + 2 *a^2*b^2 + b^4)
\[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=\int \frac {\cos ^{2}{\left (x \right )}}{a + b \cot {\left (x \right )}}\, dx \]
Time = 0.41 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.67 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=-\frac {a^{2} b \log \left (a \tan \left (x\right ) + b\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {a^{2} b \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} - a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {a \tan \left (x\right ) - b}{2 \, {\left ({\left (a^{2} + b^{2}\right )} \tan \left (x\right )^{2} + a^{2} + b^{2}\right )}} \]
-a^2*b*log(a*tan(x) + b)/(a^4 + 2*a^2*b^2 + b^4) + 1/2*a^2*b*log(tan(x)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 1/2*(a^3 - a*b^2)*x/(a^4 + 2*a^2*b^2 + b^4) + 1/2*(a*tan(x) - b)/((a^2 + b^2)*tan(x)^2 + a^2 + b^2)
Leaf count of result is larger than twice the leaf count of optimal. 155 vs. \(2 (69) = 138\).
Time = 0.26 (sec) , antiderivative size = 155, normalized size of antiderivative = 2.12 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=-\frac {a^{3} b \log \left ({\left | a \tan \left (x\right ) + b \right |}\right )}{a^{5} + 2 \, a^{3} b^{2} + a b^{4}} + \frac {a^{2} b \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} - a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} - \frac {a^{2} b \tan \left (x\right )^{2} - a^{3} \tan \left (x\right ) - a b^{2} \tan \left (x\right ) + 2 \, a^{2} b + b^{3}}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} {\left (\tan \left (x\right )^{2} + 1\right )}} \]
-a^3*b*log(abs(a*tan(x) + b))/(a^5 + 2*a^3*b^2 + a*b^4) + 1/2*a^2*b*log(ta n(x)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 1/2*(a^3 - a*b^2)*x/(a^4 + 2*a^2*b^2 + b^4) - 1/2*(a^2*b*tan(x)^2 - a^3*tan(x) - a*b^2*tan(x) + 2*a^2*b + b^3) /((a^4 + 2*a^2*b^2 + b^4)*(tan(x)^2 + 1))
Time = 12.62 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.62 \[ \int \frac {\cos ^2(x)}{a+b \cot (x)} \, dx=-{\cos \left (x\right )}^2\,\left (\frac {b}{2\,\left (a^2+b^2\right )}-\frac {a\,\mathrm {tan}\left (x\right )}{2\,\left (a^2+b^2\right )}\right )+\frac {a\,\ln \left (\mathrm {tan}\left (x\right )+1{}\mathrm {i}\right )}{4\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {a^2\,b\,\ln \left (b+a\,\mathrm {tan}\left (x\right )\right )}{{\left (a^2+b^2\right )}^2}+\frac {a\,\ln \left (\mathrm {tan}\left (x\right )-\mathrm {i}\right )\,1{}\mathrm {i}}{4\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )} \]